<?php
class Admin_Form_Project extends Zend_Form
{

    public function init()
    {
        $this->setName("admin");

        $proId = new Zend_Form_Element_Text('projectId');
        $proId->setLabel('Mã Dự án')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $proId->addFilter('Int')->setAttrib('size', 20);                                

        $projectname = new Zend_Form_Element_Text('projectName');
        $projectname->setLabel('Tên dự án')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $projectname->setAttrib('size', 60);
        
        $province = new Zend_Form_Element_Select('provinceId');
        $modelProvince = new Admin_Model_Province();
        $province->setLabel('Tỉnh/Thành phố')->setRequired(true);
        $provinceList=$modelProvince->getAllData();             
        
        $province->addMultiOption('0','--- Tỉnh/Thành phố ---');                
        foreach($provinceList as $provinceTemp) {
            $province->addMultiOption($provinceTemp['provinceid'],$provinceTemp['name']);
        }
        
        $district = new Zend_Form_Element_Select('districtId');        
        $district->setLabel('Quận/Huyện')->setRequired(true);
        $modelDistrict=new Admin_Model_District();
        $districtList=$modelDistrict->getAllData();
                                                     
        foreach($districtList as $districtTemp){
            $district->addMultiOption($districtTemp['districtid'],$districtTemp['name']);
        }
                                                             
        // submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id','submitbutton');
        $submit->setAttrib('class',"button medium");
                
        // add elements to form
        $this->addElements(array (
            $proId, $projectname, $province, $district, $submit
        ));
    }
}

